namespace SmartSoft.ADP
{
    using System;
    using System.Data;
    using System.Data.SqlClient;

    public class DmDmSpDataAccess
    {
        private WSDmDmSpDataAccess.WSDmDmSpDataAccess wDataAcess = new WSDmDmSpDataAccess.WSDmDmSpDataAccess();
        private SmartSoft.DAL.DmDmSpDataAccess oDataAcess = new SmartSoft.DAL.DmDmSpDataAccess();

        public DmDmSpDataAccess()
        {
            wDataAcess.Url = wDataAcess.Url.Replace("localhost", AdapterInstance.ServerIp);
        }

        public DataSet GetDataSet(int pi_WorkingYear)
        {
            if (AdapterInstance.IsRemoteConnected)
            {
                return wDataAcess.GetDataSet(pi_WorkingYear);
            }
            else
            {
                return oDataAcess.GetDataSet(pi_WorkingYear);
            }
        }

        public DataSet GetDataSet(int pi_WorkingYear, string ps_Code)
        {
            if (AdapterInstance.IsRemoteConnected)
            {
                return wDataAcess.GetDataSet(pi_WorkingYear, ps_Code);
            }
            else
            {
                return oDataAcess.GetDataSet(pi_WorkingYear, ps_Code);
            }
        }

        public int SaveRow(bool pb_NewChecked, DataRow row)
        {
            if (AdapterInstance.IsRemoteConnected)
            {
                return wDataAcess.SaveRow(pb_NewChecked, SmartSoft.DAL.SSDataAccess.ConvertRowToTable(row));
            }
            else
            {
                return oDataAcess.SaveRow(pb_NewChecked, row);
            }
        }
    }
}